package main

import (
	"cloudgo/handlers"
	"net/http"
)

func main() {
	mux := http.NewServeMux()
	// 处理静态文件
	files := http.FileServer(http.Dir(handlers.Public))
	mux.Handle(handlers.Static, http.StripPrefix(handlers.Static, files))
	// 访问首页，默认是登陆页
	mux.HandleFunc("/", handlers.IndexHandler)
	// 访问用户页
	mux.HandleFunc("/user/", handlers.UserHandler)
	// 用户登陆api
	mux.HandleFunc("/api/login", handlers.LoginHandler)
	// 判断用户登陆api
	mux.HandleFunc("/api/judge", handlers.JudgeHandler)
	// 退出api
	mux.HandleFunc("/api/logout", handlers.LogoutHandler)
	// 启动服务
	server := &http.Server{
		Addr:    "0.0.0.0:8080",
		Handler: mux,
	}
	server.ListenAndServe()
}
